<?  layout("../layout/default.html") { ?>
<link rel="stylesheet"
	href="${root}/Static/js/ztree/css/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script type="text/javascript"
	src="${root}/Static/js/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<div class="admin-panel">
	<div class="tab">
		<div class="tab-head">
			<strong> <? if(@data.isNew()){ ?>添加<? }else{ ?>编辑<?} ?>
			</strong> <span class="tab-more"><a href="javascript:history.go(-1)"
				class="button  button-little bg-blue  icon-step-backward"> 返回</a> </span>
			<ul class="tab-nav">
				<li class="active"><a href="#tab-set">信息</a></li>
			</ul>
		</div>
		<div class="tab-body"></div>
		<div class="tab-panel active" id="tab-set">
			<form method="post" class="form-x" action="${root}/Rule/create">
				<div class="form-group">
					<div class="label">
						<label for="sitename">模板</label>
					</div>
					<div class="field">
						<div class="input-inline clearfix">
							<input type="text" class="input input-auto" id="msgtype"
								name="msgtype" readonly="readonly" /> <input type="hidden"
								id="msg_id" value="${data.msg_id!" 0"}"/>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label for="sitename">逻辑id</label>
					</div>
					<div class="field">
						<div class="input-inline clearfix">
							<input type="text" class="input input-auto" id="logic_id"
								name="logic_id" readonly="readonly" />
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label for="sitename">订阅操作</label>
					</div>
					<div class="field">
						<div class="selected-inline selected">
							<select class="selected-inline selected" name="action"
								id="action">
								<option value="Mail">Mail</option>
								<option value="SMS">SMS</option>
								<option value="Wechat">Wechat</option>
							</select>
						</div>
					</div>
				</div>
				<div id="txtHint"></div>
			</form>
		</div>
	</div>
</div>
<?  } ?>

<script type="text/javascript">							
		 $(document).ready(function(){			
			$.get("${root}/Rule/getMessageType",function(json){
				var data = eval(json);
				$('#msgtype').attr("value",data[0]);
				$('#logic_id').attr("value",data[1]);
				$('#txtHint').empty();				  
				  var html = '';					  
			      for (var i = 2; i < data.length; i++) { 
			      	o1 = data[i]; 
			      	html+='<div class="form-group"><div class="label">';
			      	i++;
			      	o2 = data[i];		    	
			        html += '<label for="sitename">' + o1 +'</label>';
			        html += o2;
			        html += '<div class="field"><input type="text" id="' +o1+'" name="'+o1+'" class="input input-auto" />';
			        html += '</div></div>';
			      } 			      	
			     	html += '<div class="form-button"><button class="button bg-main" type="submit" onclick="return check()">提交</button></div>';
			      $('#txtHint').append(html);
			},'JSON');
		}); 
</script>	
